import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import java.rmi.*;
import java.io.*;


public class Voting extends JInternalFrame implements InterInterface
{
	public JPanel pan = new JPanel();
	public JPanel pan1 = new JPanel();
	public LineBorder lb = new LineBorder(Color.red,2);
	public LineBorder lb1 = new LineBorder(Color.red,2);
	public JTabbedPane tb = new JTabbedPane();
	
	public JPanel pan222 = new JPanel();
	public JPanel pan333 = new JPanel();
	public JPanel pan444 = new JPanel();
	public JPanel pan555 = new JPanel();
	public JPanel pan666 = new JPanel();
	public JPanel pan777 = new JPanel();
	
	public JLabel lab333 = new JLabel("Selected First :");
	public JLabel lab444 = new JLabel("Selected Second :");
	public JLabel lab555 = new JLabel("Selected Third :");
	public JLabel lab666= new JLabel("Selected Fourth :");
	public JLabel lab777 = new JLabel("Your Vote Time(min) :");
	
	public Voting()
	{
		super("Voting System",false,true,false,false);
		this.setBounds(25,10,500,410);
		setVisible(true);
		
		Container c = getContentPane();
		c.setLayout(null);
		lab5.setText("\t     Voting Of The University");
		lab5.setFont(new Font("Verdana",Font.BOLD,16));
		lab5.setEditable(false);
		lab5.setForeground(Color.black);
		lab5.setBackground(Color.gray);
		lab5.setBounds(0,0,500,30);
		c.add(lab5);
		
		
		//bt35.setBounds(150,30,200,40);
		//bt35.setFont(new Font("Verdana",Font.PLAIN,14));
		//c.add(bt35);
		
		bt35.setBounds(100,30,300,40);
		bt35.setFont(new Font("Verdana",Font.PLAIN,14));
		c.add(bt35);
		bt36.setBounds(100,200,300,40);
		bt36.setFont(new Font("Verdana",Font.PLAIN,14));
		c.add(bt36);
		
		bt35.setEnabled(true);
		bt36.setEnabled(true);
		
		pan.setLayout(null);
		pan.setBounds(20,75,450,120);
		pan.setBackground(Color.gray);
		c.add(pan);
		
		pan1.setLayout(null);
		pan1.setBounds(20,245,450,120);
		c.add(pan1);
		pan1.setBackground(Color.gray);
		
			
		pan.setBorder(lb);
		pan1.setBorder(lb1);
		pan.setVisible(false);
		pan1.setVisible(false);
		
		//lab40.setBounds();
		lab40.setBounds(40,0,350,30);
		lab40.setFont(new Font("Verdana",Font.PLAIN,14));
		pan.add(lab40);
		jsp10.setBounds(40,30,270,50);
		jsp10.setFont(new Font("Verdana",Font.PLAIN,13));
		jsp10.setBorder(new LineBorder(Color.white,2));
		//tfield01.setBackground(Color.blue);
		pan.add(jsp10);
		bt37.setBounds(325,30,110,40);
		bt37.setFont(new Font("Verdana",Font.PLAIN,13));
		bt37.setBorder(new LineBorder(Color.white,2));
		pan.add(bt37);
		bt38.setBounds(325,70,110,37);
		bt38.setFont(new Font("Verdana",Font.PLAIN,13));
		bt38.setBorder(new LineBorder(Color.white,2));
		pan.add(bt38);
		lab41.setBounds(40,83,140,30);
		lab41.setFont(new Font("Verdana",Font.PLAIN,14));
		pan.add(lab41);
		txf41.setBounds(180,88,130,20);
		txf41.setFont(new Font("Verdana",Font.PLAIN,13));
		txf41.setBorder(new LineBorder(Color.white,2));
		pan.add(txf41);
		bt37.setEnabled(true);
		bt38.setEnabled(false);
		bt39.setEnabled(true);
		bt40.setEnabled(false);
		
		bt39.setBounds(325,30,110,40);
		bt39.setFont(new Font("Verdana",Font.PLAIN,13));
		bt39.setBorder(new LineBorder(Color.white,2));
		pan1.add(bt39);
		bt40.setBounds(325,70,110,37);
		bt40.setFont(new Font("Verdana",Font.PLAIN,13));
		bt40.setBorder(new LineBorder(Color.white,2));
		pan1.add(bt40);
		pan222.setLayout(null);
		t111.setBackground(Color.white);
		jsp111.setBounds(0,0,290,60);
		pan222.add(jsp111);
		pan333.setLayout(null);
		lab333.setBounds(20,5,150,20);
		txf42.setBounds(20,28,220,20);
		txf42.setBorder(new LineBorder(Color.green,2));
		pan333.add(lab333);
		pan333.add(txf42);
		pan444.setLayout(null);
		lab444.setBounds(20,5,150,20);
		txf43.setBounds(20,28,220,20);
		txf43.setBorder(new LineBorder(Color.green,2));
		pan444.add(lab444);
		pan444.add(txf43);
		pan555.setLayout(null);
		lab555.setBounds(20,5,150,20);
		txf44.setBounds(20,28,220,20);
		txf44.setBorder(new LineBorder(Color.green,2));
		pan555.add(lab555);
		pan555.add(txf44);
		pan666.setLayout(null);
		lab666.setBounds(20,5,150,20);
		txf45.setBounds(20,28,220,20);
		txf45.setBorder(new LineBorder(Color.green,2));
		pan666.add(lab666);
		pan666.add(txf45);
		pan777.setLayout(null);
		lab777.setBounds(20,5,150,20);
		txf46.setBounds(20,28,200,20);
		txf46.setBorder(new LineBorder(Color.green,2));
		pan777.add(lab777);
		pan777.add(txf46);
		tb.addTab("Vote Ques",pan222);
		tb.addTab("Sec 1",pan333);
		tb.addTab("Sec 2",pan444);
		tb.addTab("Sec 3",pan555);
		tb.addTab("Sec 4",pan666);
		tb.addTab("Time",pan777);
		tb.setBounds(10,10,300,100);
		tb.setBorder(new LineBorder(Color.white,2));
		pan1.add(tb);
		
		bt35.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				pan.setVisible(true);
			}
		}
		);
		bt36.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				pan1.setVisible(true);
			}
		}
		);
		bt37.addActionListener(new ActionListener()
		{
			
			
			public void actionPerformed(ActionEvent e)
			{
				try {
				Integer.parseInt(txf41.getText());
			
			if(t10.getText().equals(""))
			JOptionPane.showMessageDialog(null,"Server Configuare Error..","Error",JOptionPane.ERROR_MESSAGE);
			else {
			try
			{
			MainServerImpl msi = new MainServerImpl();
			Naming.rebind("MainServer",msi);
			JOptionPane.showMessageDialog(null,"Server Start Successfully...\nThanks","Thanks",JOptionPane.INFORMATION_MESSAGE);
			System.out.println("Waiting For clients....");
			
			
			Thread12 thr1 = new Thread12("Thread1");
			thr1.start();
			
		}
		catch(Exception ex)
		{
			System.out.println("Error Occured at the initializing server Object");
			ex.printStackTrace();
		}
			}
		}
			catch(Exception x)
			{
				JOptionPane.showMessageDialog(null,"Server Configuare Error..","Error",JOptionPane.ERROR_MESSAGE);
		}	}	
		}
		);
		bt38.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				voteynresult vl = new voteynresult();
				vl.voteynresult1();	
				desktop.add(vl);
				try{
				vl.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
		}
		);
		bt39.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
			try {
				Integer.parseInt(txf46.getText());
				if(t111.getText().equals("") || txf42.getText().equals("") || txf43.getText().equals("") || txf44.getText().equals("") || txf45.getText().equals(""))
				JOptionPane.showMessageDialog(null,"Please Configuare the Server Correctly..","Information",JOptionPane.INFORMATION_MESSAGE);
				else {
				
			try
				{
				MainServerImpl msi = new MainServerImpl();
				Naming.rebind("MainServer",msi);
				JOptionPane.showMessageDialog(null,"Server Start Successfully...\nThanks","Thanks",JOptionPane.INFORMATION_MESSAGE);			
				System.out.println("Waiting For clients....");
			
				Thread13 thr1 = new Thread13("Thread1");
				thr1.start();
			
				}
			catch(Exception ex)
				{
				System.out.println("Error Occured at the initializing server Object");
				ex.printStackTrace();
			}
			}
			}
			catch(Exception excep)		
			{
				JOptionPane.showMessageDialog(null,"Server Configuration Error..","Error",JOptionPane.ERROR_MESSAGE);
			}
			
			}
		}
		);
		bt40.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				votesecresult vl = new votesecresult();
				vl.votesecresult1();	
				desktop.add(vl);
				try{
				vl.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		);
		try
		{
			UIManager.setLookAndFeel(looks[1].getClassName());
			SwingUtilities.updateComponentTreeUI(this);
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
	
}
